package com.af.monitorModule.common;


/**
 * 监控类型枚举配置
 * @author lyz
 */
public enum MonitorTypeEnum {
    //信息推送
    SEND(1, "信息推送","用于服务所有其他python脚本的心跳处理、数据推送、异常警报推送等的功能","该脚本部署在_._._._服务器，遵循默认部署路径。"),
    SQL(2, "数据库监控","监控指定的业务数据库，抓取慢SQL，处理阻塞SQL，审查数据库运行的各种意外情况","该脚本部署在_._._._服务器，遵循默认部署路径。"),
    TOMCAT_ALIVE(3, "Tomcat存活监控","监控配置的运行服务，定时查看运行的服务状态，对于状态异常的服务，进行服务自愈，尽量做到用户轻感知","该脚本部署在_._._._服务器，遵循默认部署路径。"),
    NGINX_LOG(4, "Nginx日志审计","实时读取对应格式的log文件，进行各个请求状态的筛查，对于超时、异常的请求进行报警","该脚本部署在_._._._服务器，遵循默认部署路径。"),
    TOMCAT_LOG(5, "Tomcat日志审计","实时读取对应格式的log文件，进行各个请求状态的筛查，对于超时、异常的请求进行报警","该脚本部署在_._._._服务器，遵循默认部署路径。"),
    SERVER_PERFORMANCE(6, "服务器性能监控","获取所在宿主机的服务器信息，包括CPU、内存、硬盘、IO等多方面的监控和统计，对于异常指标及时报警","该脚本部署在_._._._服务器，遵循默认部署路径。"),
    TIMER_JOB(7, "定时任务","JAVA工具，用于连接到指定数据库，从运维系统中获取对应的任务执行并返回结果，用于定时的SQL任务执行","该脚本部署在_._._._服务器，遵循默认部署路径。"),
    LOG_COLLECTION(8, "日志收集","python脚本，用来抓取业务逻辑日志，并推送服务器","该脚本部署在_._._._服务器，遵循默认部署路径。"),
    ;

    private final Integer id;

    private final String monitorName;

    private final String monitorInner;

    private final String remarks;



    MonitorTypeEnum(Integer id, String monitorName, String monitorInner, String remarks) {
        this.id = id;
        this.monitorName = monitorName;
        this.monitorInner = monitorInner;
        this.remarks = remarks;
    }

    public Integer getId() {
        return id;
    }

    public String getMonitorName() {
        return monitorName;
    }

    public String getMonitorInner() {
        return monitorInner;
    }

    public String getRemarks() {
        return remarks;
    }

    /**
     * 获取所有的监控的名称并返回ID_名称
     */
    public static String[] getAllMonitorName(){
        MonitorTypeEnum[] monitors = MonitorTypeEnum.values();
        String [] monitorNames = new String[monitors.length];
        for (int i = 0; i < monitors.length; i++) {
            monitorNames[i] = monitors[i].getId() + "_" + monitors[i].getMonitorName();
        }
        return monitorNames;
    }

    /**
     * 根据前台传来的id获取对应枚举的填充值
     * @param id
     */
    public static MonitorTypeEnum getOneById(int id){
        MonitorTypeEnum[] monitors = MonitorTypeEnum.values();
        for (MonitorTypeEnum monitor : monitors) {
            if (id == monitor.getId()) {
                return monitor;
            }
        }
        return null;
    }


}
